////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Copyright (c) 2017-2018 Qualcomm Technologies, Inc.
// All Rights Reserved.
// Confidential and Proprietary - Qualcomm Technologies, Inc.
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// THIS IS AUTO-GENERATED CODE.  PLEASE DO NOT EDIT (File bug reports against tools).
///
/// Auto-generated by: ParameterParser V1.1.4
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// @file  aecarbitration.cpp
/// @brief Auto-generated Chromatix parameter file
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

#include "aecarbitration.h"
#include "parametersetmanager.h"

AECARBITRATION_NAMESPACE_BEGIN

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// Default Constructor
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
AECCoreArbitrationTypeClass::AECCoreArbitrationTypeClass(
    const CHAR* name)
    : ParameterModule(name, MAJOR, MINOR, PATCH, 0, 0, 0, 0)
{
    PARAMETER_INITIALIZE(SymbolTableID);
    PARAMETER_INITIALIZE(module_version);
    PARAMETER_INITIALIZE(expTablesCount);
    PARAMETER_INITIALIZE(expTablesID);
    PARAMETER_INITIALIZE(expTables);
    PARAMETER_INITIALIZE(minPreviewVertBlankTime);
    PARAMETER_INITIALIZE(enableEVExpTableAdj);
    PARAMETER_INITIALIZE(enableEVGainCapping);
    PARAMETER_INITIALIZE(maxEVCappingGain);
    PARAMETER_INITIALIZE(ISOData);
    PARAMETER_INITIALIZE(antibandingVsFPSMethod);
    PARAMETER_INITIALIZE(enablePreviewManualISO);
    PARAMETER_INITIALIZE(enablePreviewManualExpTime);
    PARAMETER_INITIALIZE(enablePreviewManualFull);
}

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// Constructor
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
AECCoreArbitrationTypeClass::AECCoreArbitrationTypeClass(
    const CHAR* name,
    UINT32 modeId,
    UINT16 mode,
    UINT16 subMode,
    UINT32 group)
    : ParameterModule(name, MAJOR, MINOR, PATCH, modeId, mode, subMode, group)
{
    PARAMETER_INITIALIZE(SymbolTableID);
    PARAMETER_INITIALIZE(module_version);
    PARAMETER_INITIALIZE(expTables);
    PARAMETER_INITIALIZE(minPreviewVertBlankTime);
    PARAMETER_INITIALIZE(enableEVExpTableAdj);
    PARAMETER_INITIALIZE(enableEVGainCapping);
    PARAMETER_INITIALIZE(maxEVCappingGain);
    PARAMETER_INITIALIZE(ISOData);
    PARAMETER_INITIALIZE(antibandingVsFPSMethod);
    PARAMETER_INITIALIZE(enablePreviewManualISO);
    PARAMETER_INITIALIZE(enablePreviewManualExpTime);
    PARAMETER_INITIALIZE(enablePreviewManualFull);
}

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// Destructor
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
AECCoreArbitrationTypeClass::~AECCoreArbitrationTypeClass()
{
    UnloadAECCoreArbitrationType(this);
}

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// GetName
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
const CHAR* AECCoreArbitrationTypeClass::GetName(
    const CHAR* type)
{
    const CHAR* name = type;
    CHAR temp[ParameterFileSymbolTableEntry::TYPE_LEN + 1];
    if (PARAMETER_STRCMP(type, ParameterFileSymbolTableEntry::GetType(temp, "Arbitration")) == 0)
    {
        name = "Arbitration";
    }
    return name;
}

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// Load ISOSettingType
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
BOOL AECCoreArbitrationTypeClass::LoadISOSettingType(
    ParameterFileSymbolTableEntry* entry,
    ISOSettingType* structure)
{
    BOOL result = TRUE;
    result = result && entry->ReadFloat(&structure->previewISO100Gain);
    result = result && entry->ReadBoolean(&structure->enableAntiBandingVsISOPrio);
    result = result && entry->ReadBoolean(&structure->enableISOQuantization);

    // Reading structure->thresQuantizationISOValue from the symbol table
    {
        result = result && entry->ReadUInt32(&structure->thresQuantizationISOValueCount);
        structure->thresQuantizationISOValueID = entry->ID;
        ParameterFileSymbolTableEntry* pointerEntry1 = entry->Table->ReadPointerEntry(entry);
        result = result && pointerEntry1 != NULL;
        if (result)
        {
            structure->thresQuantizationISOValue   = PARAMETER_NEW FLOAT[structure->thresQuantizationISOValueCount];
        }
        if (!result || structure->thresQuantizationISOValue == NULL)
        {
            structure->thresQuantizationISOValueCount = 0;
        }
        for (UINT32 i = 0; result && i < structure->thresQuantizationISOValueCount; i++)
        {
            result = result && pointerEntry1->ReadFloat(&structure->thresQuantizationISOValue[i]);
        }
    }

    // Reading structure->quantizedISOValue from the symbol table
    {
        result = result && entry->ReadUInt32(&structure->quantizedISOValueCount);
        structure->quantizedISOValueID = entry->ID;
        ParameterFileSymbolTableEntry* pointerEntry1 = entry->Table->ReadPointerEntry(entry);
        result = result && pointerEntry1 != NULL;
        if (result)
        {
            structure->quantizedISOValue   = PARAMETER_NEW FLOAT[structure->quantizedISOValueCount];
        }
        if (!result || structure->quantizedISOValue == NULL)
        {
            structure->quantizedISOValueCount = 0;
        }
        for (UINT32 i = 0; result && i < structure->quantizedISOValueCount; i++)
        {
            result = result && pointerEntry1->ReadFloat(&structure->quantizedISOValue[i]);
        }
    }

    return result;
}

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// Load ExposureKneeType
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
BOOL AECCoreArbitrationTypeClass::LoadExposureKneeType(
    ParameterFileSymbolTableEntry* entry,
    ExposureKneeType* structure)
{
    BOOL result = TRUE;
    result = result && entry->ReadFloat(&structure->gain);
    result = result && entry->ReadUInt64(&structure->expTime);
    structure->incrementPriority = (aecglobalelements::AECExpIncPrioType)entry->ReadEnum(&result);
    result = result && entry->ReadFloat(&structure->expIndex);

    return result;
}

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// Load ExposureTableType
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
BOOL AECCoreArbitrationTypeClass::LoadExposureTableType(
    ParameterFileSymbolTableEntry* entry,
    ExposureTableType* structure)
{
    BOOL result = TRUE;
    result = result && entry->ReadFloat(&structure->sensitivityCorrectionFactor);

    // Reading structure->expKneeEntries from the symbol table
    {
        result = result && entry->ReadUInt32(&structure->expKneeEntriesCount);
        structure->expKneeEntriesID = entry->ID;
        ParameterFileSymbolTableEntry* pointerEntry1 = entry->Table->ReadPointerEntry(entry);
        result = result && pointerEntry1 != NULL;
        if (result)
        {
            structure->expKneeEntries   = PARAMETER_NEW ExposureKneeType[structure->expKneeEntriesCount];
        }
        if (!result || structure->expKneeEntries == NULL)
        {
            structure->expKneeEntriesCount = 0;
        }
        for (UINT32 i = 0; result && i < structure->expKneeEntriesCount; i++)
        {
            result = result && LoadExposureKneeType(pointerEntry1, &structure->expKneeEntries[i]);
        }
    }
    result = result && entry->ReadFloat(&structure->thresAntiBandingMinExpTimePct);

    return result;
}

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// Load AECCoreArbitrationType
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
BOOL AECCoreArbitrationTypeClass::LoadAECCoreArbitrationType(
    ParameterFileSymbolTableEntry* entry,
    AECCoreArbitrationType* structure)
{
    BOOL result = TRUE;
    result = result && Loadmodule_versionStruct(entry, &structure->module_version);

    // Reading structure->expTables from the symbol table
    {
        result = result && entry->ReadUInt32(&structure->expTablesCount);
        structure->expTablesID = entry->ID;
        ParameterFileSymbolTableEntry* pointerEntry1 = entry->Table->ReadPointerEntry(entry);
        result = result && pointerEntry1 != NULL;
        if (result)
        {
            structure->expTables   = PARAMETER_NEW ExposureTableType[structure->expTablesCount];
        }
        if (!result || structure->expTables == NULL)
        {
            structure->expTablesCount = 0;
        }
        for (UINT32 i = 0; result && i < structure->expTablesCount; i++)
        {
            result = result && LoadExposureTableType(pointerEntry1, &structure->expTables[i]);
        }
    }
    result = result && entry->ReadUInt64(&structure->minPreviewVertBlankTime);
    result = result && entry->ReadBoolean(&structure->enableEVExpTableAdj);
    result = result && entry->ReadBoolean(&structure->enableEVGainCapping);
    result = result && entry->ReadFloat(&structure->maxEVCappingGain);
    result = result && LoadISOSettingType(entry, &structure->ISOData);
    structure->antibandingVsFPSMethod = (aecglobalelements::AECAntibandingVsFPSMethod)entry->ReadEnum(&result);
    result = result && entry->ReadBoolean(&structure->enablePreviewManualISO);
    result = result && entry->ReadBoolean(&structure->enablePreviewManualExpTime);
    result = result && entry->ReadBoolean(&structure->enablePreviewManualFull);

    return result;
}

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// Load module_versionStruct
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
BOOL AECCoreArbitrationTypeClass::Loadmodule_versionStruct(
    ParameterFileSymbolTableEntry* entry,
    AECCoreArbitrationType::module_versionStruct* structure)
{
    BOOL result = TRUE;
    result = result && entry->ReadInt32(&structure->major_revision);
    result = result && entry->ReadInt32(&structure->minor_revision);
    result = result && entry->ReadInt32(&structure->incr_revision);

    return result;
}

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// Unload ISOSettingType
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
void AECCoreArbitrationTypeClass::UnloadISOSettingType(
    ISOSettingType* structure)
{
    PARAMETER_DELETE[] structure->thresQuantizationISOValue;
    PARAMETER_DELETE[] structure->quantizedISOValue;
}

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// Unload ExposureTableType
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
void AECCoreArbitrationTypeClass::UnloadExposureTableType(
    ExposureTableType* structure)
{
    PARAMETER_DELETE[] structure->expKneeEntries;
}

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// Unload AECCoreArbitrationType
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
void AECCoreArbitrationTypeClass::UnloadAECCoreArbitrationType(
    AECCoreArbitrationType* structure)
{
    for (UINT32 i = 0; i < structure->expTablesCount; i++)
    {
        UnloadExposureTableType(&structure->expTables[i]);
    }
    PARAMETER_DELETE[] structure->expTables;
    UnloadISOSettingType(&structure->ISOData);
}

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// Parse symbol table entry, and return a new object
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
ParameterModule* AECCoreArbitrationTypeClass::Parse(
    ParameterSetManager* manager,
    ParameterFileSymbolTableEntry* entry) const
{
    AECCoreArbitrationTypeClass* cls = NULL;

    if (PARAMETER_STRCMP(Type, entry->Type) == 0 && Major == entry->Major &&
        Minor == entry->Minor && Patch == entry->Patch)
    {
        cls = PARAMETER_NEW AECCoreArbitrationTypeClass(GetName(entry->Type), 
            entry->ModeId, entry->Mode, entry->SubMode, entry->Group);
        if (cls != NULL)
        {
            BOOL result = TRUE;

            cls->SymbolTableID = entry->ID;
            cls->ID            = entry->ID;

            result = result && LoadAECCoreArbitrationType(entry, cls);

            if (!result)
            {
                PARAMETER_DELETE cls;
                cls = NULL;
            }
        }
    }
    return (ParameterModule*)cls;
}


AECARBITRATION_NAMESPACE_END
